package com.cjr.sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.cjr.sentinel.feign.ProviderFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/demo")
public class SentinelDemoController {
    @Autowired
    ProviderFeign providerFeign;

    @SentinelResource(value = "cjrhello",blockHandler ="blockHandlerHello" )
    @RequestMapping("/hello")
    public String hello(){
        return "hello cjr";
    }

    public String blockHandlerHello(BlockException e) {
        return "限流了";
    }


    @RequestMapping("/provider")
    public String pro(){
      return   providerFeign.pro();
    }
}
